//
//  ChooseProTableViewCell.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/8/9.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "ChooseProTableViewCell.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@implementation ChooseProTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


- (void)createSubViews{
    //  头像
    self.headImageView = [[UIImageView alloc]init];
    self.headImageView.image = [UIImage imageNamed:@"touxiang"];
//    self.headImageView.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.headImageView];
    
    
    // 标题
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.text = @"创业生态园";
//    self.titleLabel.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    
    
    // 报名项目
    self.proLabel = [[UILabel alloc]init];
    self.proLabel.font = [UIFont systemFontOfSize:12];
    self.proLabel.textColor = [UIColor lightGrayColor];
    self.proLabel.textAlignment = NSTextAlignmentLeft;
//    self.proLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.proLabel];
    
    
    // 报名时间
    self.timeLabel = [[UILabel alloc]init];
    self.timeLabel.font = [UIFont systemFontOfSize:12];
    self.timeLabel.textColor = [UIColor lightGrayColor];
    self.timeLabel.textAlignment = NSTextAlignmentLeft;
//    self.timeLabel.backgroundColor = [UIColor magentaColor];
    [self.contentView addSubview:self.timeLabel];
    
    //同意
    self.agree = [[UIButton alloc]init];
//    self.agree.backgroundColor = [UIColor yellowColor];
    self.agree.layer.borderWidth = 1;
    self.agree.layer.cornerRadius = 5;
    [self.agree setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.agree setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
    self.agree.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.agree];
    
    // 不同意
    self.unAgree = [[UIButton alloc]init];
    self.unAgree.layer.borderWidth = 1;
    self.unAgree.layer.cornerRadius = 5;
    [self.unAgree setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.unAgree setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
    self.unAgree.layer.borderColor = [COLOR_RGBA(217, 217, 217, 1) CGColor];
    self.unAgree.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.unAgree];
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.headImageView.frame = CGRectMake(10, 15, (self.contentView.frame.size.height - 30)/ 3 * 2 , (self.contentView.frame.size.height - 30) / 3 * 2);
    self.titleLabel.frame = CGRectMake(self.headImageView.maxX + 10, self.headImageView.y, WIDTH - self.headImageView.maxX - 20, self.headImageView.frame.size.height / 3);

    self.proLabel.frame = CGRectMake(self.titleLabel.x, self.titleLabel.maxY, WIDTH - self.headImageView.maxX - 20, self.headImageView.frame.size.height / 3);
    self.timeLabel.frame = CGRectMake(self.titleLabel.x, self.proLabel.maxY,WIDTH - self.headImageView.maxX - 20, self.headImageView.frame.size.height / 3);
    self.agree.frame = CGRectMake(WIDTH / 2 - 20, self.headImageView.maxY + 8, WIDTH / 4 , HEIGHT / 3 - 16 );
    self.unAgree.frame = CGRectMake(self.agree.maxX + 7  , self.headImageView.maxY + 8, WIDTH / 4, HEIGHT / 3 - 16);
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
